<?php

require_once(sfConfig::get('sf_lib_dir').'/filter/base/BaseFormFilterPropel.class.php');

/**
 * Profil filter form base class.
 *
 * @package    dnevnik
 * @subpackage filter
 * @author     Your name here
 * @version    SVN: $Id: sfPropelFormFilterGeneratedTemplate.php 16976 2009-04-04 12:47:44Z fabien $
 */
class BaseProfilFormFilter extends BaseFormFilterPropel
{
  public function setup()
  {
    $this->setWidgets(array(
      'tip'                => new sfWidgetFormFilterInput(),
      'prezime'            => new sfWidgetFormFilterInput(),
      'ime'                => new sfWidgetFormFilterInput(),
      'e_mail'             => new sfWidgetFormFilterInput(),
      'username'           => new sfWidgetFormFilterInput(),
      'password'           => new sfWidgetFormFilterInput(),
      'plain_password'     => new sfWidgetFormFilterInput(),
      'pol'                => new sfWidgetFormFilterInput(),
      'adresa'             => new sfWidgetFormFilterInput(),
      'telefon'            => new sfWidgetFormFilterInput(),
      'mobilni'            => new sfWidgetFormFilterInput(),
      'last_activ'         => new sfWidgetFormFilterInput(),
      'poruka_profil_list' => new sfWidgetFormPropelChoice(array('model' => 'Poruka', 'add_empty' => true)),
    ));

    $this->setValidators(array(
      'tip'                => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'prezime'            => new sfValidatorPass(array('required' => false)),
      'ime'                => new sfValidatorPass(array('required' => false)),
      'e_mail'             => new sfValidatorPass(array('required' => false)),
      'username'           => new sfValidatorPass(array('required' => false)),
      'password'           => new sfValidatorPass(array('required' => false)),
      'plain_password'     => new sfValidatorPass(array('required' => false)),
      'pol'                => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'adresa'             => new sfValidatorPass(array('required' => false)),
      'telefon'            => new sfValidatorPass(array('required' => false)),
      'mobilni'            => new sfValidatorPass(array('required' => false)),
      'last_activ'         => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'poruka_profil_list' => new sfValidatorPropelChoice(array('model' => 'Poruka', 'required' => false)),
    ));

    $this->widgetSchema->setNameFormat('profil_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function addPorukaProfilListColumnCriteria(Criteria $criteria, $field, $values)
  {
    if (!is_array($values))
    {
      $values = array($values);
    }

    if (!count($values))
    {
      return;
    }

    $criteria->addJoin(PorukaProfilPeer::PROFIL_ID, ProfilPeer::ID);

    $value = array_pop($values);
    $criterion = $criteria->getNewCriterion(PorukaProfilPeer::PORUKA_ID, $value);

    foreach ($values as $value)
    {
      $criterion->addOr($criteria->getNewCriterion(PorukaProfilPeer::PORUKA_ID, $value));
    }

    $criteria->add($criterion);
  }

  public function getModelName()
  {
    return 'Profil';
  }

  public function getFields()
  {
    return array(
      'id'                 => 'Number',
      'tip'                => 'Number',
      'prezime'            => 'Text',
      'ime'                => 'Text',
      'e_mail'             => 'Text',
      'username'           => 'Text',
      'password'           => 'Text',
      'plain_password'     => 'Text',
      'pol'                => 'Number',
      'adresa'             => 'Text',
      'telefon'            => 'Text',
      'mobilni'            => 'Text',
      'last_activ'         => 'Number',
      'poruka_profil_list' => 'ManyKey',
    );
  }
}
